﻿Imports System.Text.RegularExpressions
Public Class Class1

    Public Function ValidarCorreo(ByVal correo As String) As Boolean
        'DESPUES DE IMPORTAR: System.Text.RegularExpressions
        Dim re As New Regex("\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+")
        Dim valido As Boolean
        If re.IsMatch(correo) Then
            valido = True
        Else
            MsgBox("Formato de correo erróneo", vbCritical, "Error")
            valido = False
        End If
        re = Nothing
        Return valido
    End Function

    Public Function ValidarApellidos(ByVal apellidos As String) As Boolean
        Dim valido As Boolean
        If apellidos.StartsWith(" ") Then
            apellidos = apellidos.Trim
            valido = True
        ElseIf apellidos.EndsWith(" ") Then
            apellidos = apellidos.Trim + " "
            valido = False
        End If
        Return valido
    End Function
End Class
